<template>
  <div class="list-main">
    <van-tabs type="card">
      <van-tab title="教师评教活动列表">
        <van-list
          v-model="loading1"
          :finished="finished1"
          :error.sync="error1"
          finished-text="没有更多了"
          @load="onLoad1"
        >
          <van-cell-group>
            <van-cell
              v-for="act in activityList1"
              :key="act.courseclassId + act.teacherId"
              is-link
              @click="gotoTeacherList(act.evalutionActivityId,act.title)"
              class="vo-list"
            >
              <template #title>
                <span class="custom-title van-ellipsis">{{ act.title }}</span>
                <!-- <van-tag v-if="vo.courseType==3" type="primary" class="vo-state">教师评价表<van-icon name="question-o" /></van-tag>
            <van-tag v-if="vo.courseType==3" type="success" class="vo-state">课程评价表<van-icon name="completed" /></van-tag>
            <van-tag v-if="vo.courseType==3" type="danger" class="vo-state">学生评价表<van-icon name="failure" /></van-tag> -->
              </template>
              <template #label>
                <div class="vo">
                  <div class="vo-info">
                    <div class="teacher-name">学期：{{ act.term }}</div>
                  </div>
                  <div class="vo-info-state" v-if="false">
                    <div class="vo-date">
                      日期：{{ act.beginTime }} - {{ act.endTime }}
                    </div>
                    <div class="judge-state">
                      <van-tag
                        v-if="act.status == 2"
                        type="primary"
                        class="judge-state"
                        >待评价<van-icon name="question-o"
                      /></van-tag>
                      <van-tag
                        v-if="act.status == 3"
                        type="success"
                        class="judge-state"
                        >已评价<van-icon name="completed"
                      /></van-tag>
                      <van-tag
                        v-if="act.status == 4"
                        type="danger"
                        class="judge-state"
                        >已结束<van-icon name="failure"
                      /></van-tag>
                    </div>
                  </div>
                </div>
              </template>
            </van-cell>
          </van-cell-group>
        </van-list>
      </van-tab>
      <van-tab title="辅导员评教活动列表">
        <van-list
          v-model="loading2"
          :finished="finished2"
          :error.sync="error2"
          finished-text="没有更多了"
          @load="onLoad2"
        >
          <van-cell-group>
            <van-cell
              v-for="act in activityList2"
              :key="act.courseclassId + act.teacherId"
              is-link
              @click="gotoTeacherList(act.evalutionActivityId)"
              class="vo-list"
            >
              <template #title>
                <span class="custom-title van-ellipsis">{{ act.title }}</span>
                <!-- <van-tag v-if="vo.courseType==3" type="primary" class="vo-state">教师评价表<van-icon name="question-o" /></van-tag>
            <van-tag v-if="vo.courseType==3" type="success" class="vo-state">课程评价表<van-icon name="completed" /></van-tag>
            <van-tag v-if="vo.courseType==3" type="danger" class="vo-state">学生评价表<van-icon name="failure" /></van-tag> -->
              </template>
              <template #label>
                <div class="vo">
                  <div class="vo-info">
                    <div class="teacher-name">学期：{{ act.term }}</div>
                  </div>
                  <div class="vo-info-state" v-if="false">
                    <div class="vo-date">
                      日期：{{ act.beginTime }} - {{ act.endTime }}
                    </div>
                    <div class="judge-state">
                      <van-tag
                        v-if="act.status == 2"
                        type="primary"
                        class="judge-state"
                        >待评价<van-icon name="question-o"
                      /></van-tag>
                      <van-tag
                        v-if="act.status == 3"
                        type="success"
                        class="judge-state"
                        >已评价<van-icon name="completed"
                      /></van-tag>
                      <van-tag
                        v-if="act.status == 4"
                        type="danger"
                        class="judge-state"
                        >已结束<van-icon name="failure"
                      /></van-tag>
                    </div>
                  </div>
                </div>
              </template>
            </van-cell>
          </van-cell-group>
        </van-list>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import { getStatisticsList } from "@/api/pingjiao/statistics.js";
import { listTeacherStatistics } from "@/api/pingjiao/statistics.js";
export default {
  name: "StatisticsList",
  data() {
    return {
      //教师数据  为1
      activityList1: [
        {
          beginTime: "2022-10-24",
          endTime: "2022-10-25",
          evalutionActivityId: 1,
          title: "评教活动1",
          term: "2022-2023-01", //学期
          time: 1, //本学期被评次数
          status: 2, //2等待评价  3等待统计  4活动结束
        },
      ],
      loading1: false, //列表加载中
      error1: false, //列表加载出错
      finished1: false, //列表加载完成
      //辅导员数据  为2
      activityList2: [
        {
          beginTime: "2022-10-24",
          endTime: "2022-10-25",
          evalutionActivityId: 1,
          title: "评教活动1",
          term: "2022-2023-01", //学期
          time: 1, //本学期被评次数
          status: 2, //2等待评价  3等待统计  4活动结束
        },
      ],
      loading2: false, //列表加载中
      error2: false, //列表加载出错
      finished2: false, //列表加载完成
       // 查询参数
       queryParams: {
        // pageNum: 1,
        // pageSize: 10,
        evalutionActivityId: null,
        evalutionPaperId: null,
        teacherId: null,
        courseclassId: null,
        studentId: null,
        status: null,
        generateTime: null,
        sumScore: null,
        state: null
      },
    };
  },
  created() {
    console.log("statisticsList");
    this.$emit("show", 0); //传递给父组件改变tab的激活active样式
  },
  watch: {},
  methods: {
    onLoad1() {
      this.loading1 = true; // 加载状态开始
      console.log("get statistics list1");
      getStatisticsList(1)
        .then((res) => {
          this.activityList1 = res.data;
          this.loading1 = false; // 加载状态结束
          this.finished1 = true; //提示列表加载完成
          console.log(" get statistics list res", res);
        })
        .catch((error) => {
          console.log("get statistics res error", error);
          this.error = true; //提示列表加载出错点击重新加载
        });
    },
    onLoad2() {
      this.loading2 = true; // 加载状态开始
      console.log("get statistics list2");
      getStatisticsList(2)
        .then((res) => {
          this.activityList2 = res.data;
          this.loading2 = false; // 加载状态结束
          this.finished2 = true; //提示列表加载完成
          console.log(" get statistics list res", res);
        })
        .catch((error) => {
          console.log("get statistics res error", error);
          this.error = true; //提示列表加载出错点击重新加载
        });
    },
    gotoTeacherList: function (evalutionActivityId,title) {
      // console.log("evalutionActivityId",evalutionActivityId);
      // this.queryParams.evalutionActivityId=evalutionActivityId
      // listTeacherStatistics(this.queryParams).then((res) => {
      //     console.log(" listTeacherStatistics res", res);
      //   })
      //   .catch((error) => {
      //     console.log("get statistics res error", error);
      //     this.error = true; //提示列表加载出错点击重新加载
      //   });
      this.$router.push({
        path: "/dingding/statisticsListSelect",
        query: {
          evalutionActivityId: evalutionActivityId,
          title: title,
        },
      });
    },
  },
};
</script>

<style  rel="stylesheet/scss" lang="scss">
.list-main {
  height: 100%;
  width: 100%;
  overflow: hidden;
}
.vo-list {
  margin: 0px auto;
  width: 95%;
  border-bottom: 2px dashed #eee;
}
.vo {
  display: flex;
  flex-direction: column;
}
.custom-title {
  font-size: 13pt;
  font-weight: bolder;
}
.vo-info {
  width: 100%;
  overflow: hidden;
  font-size: 12pt;
  line-height: 30px;
}
.vo-info .teacher-name,
.vo-info .course-name {
  width: 140px;
  float: left;
}
.vo-info-state {
  font-size: 2pt;
  display: flex;
}
.judge-state {
  flex: 1;
  font-size: 2pt;
  text-align: right;
}
.vo-date {
  flex: 1;
  line-height: 25px;
}
</style>
